package com.test.socket;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.logging.Logger;

public class TCPEchoServerExecutor {

	public static void main(String[] args)throws IOException{
		int echoServPort = 8086;//server port
		//create a server socket to accept client connection requests
		ServerSocket serverSock = new ServerSocket(echoServPort);
		Logger logger = Logger.getLogger("practical");
		Executor service = Executors.newCachedThreadPool();//dispatch svc
		//run forever, accepting and spawning a thread for each connection
		while(true){
			Socket clntSock = serverSock.accept(); //block waiting for connection
			service.execute(new CompressProtocol(clntSock, logger));
		}
		
	}
}
